package utiles;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;

/**
 * Clase que monitoriza los logs de la aplicación.
 * @author Efren
 */
public class Logger {
    private static Logger log;
    private static BufferedWriter berr;
    private static BufferedWriter binf;
    
    private Logger(){
        try {
            berr = new BufferedWriter(new FileWriter("errores.txt"));
            binf = new BufferedWriter(new FileWriter("informacion.txt"));
        }catch(IOException ex){
        }
    }
    public static void printInformation(String info){
        if (Logger.log == null){
            log = new Logger();
        }
        try {
            binf.write(info);
            binf.newLine();
            binf.flush();
        } catch (IOException ex) {
        }
    }
    public static void printError(String error){
        if (Logger.log == null){
            log = new Logger();
        }
        try {
            berr.write(error);
            berr.newLine();
            berr.flush();
        } catch (IOException ex) {
            java.util.logging.Logger.getLogger(Logger.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
